<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace App\Listeners;

use Illuminate\Auth\Events\Login;
use App\Models\Auth\Admin;

class AdminLogin {

	/**
	 * Create the event listener.
	 */
	public function __construct() {
		//
	}

	/**
	 * Handle the event.
	 */
	public function handle(Login $event): void {
		$admin = $event->user;

		$admin->last_login_ip = request()->ip();
		$admin->last_login_at = date('Y-m-d H:i:s');
		$admin->save();
	}
}
